package com.work.model;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the Sprints database table.
 * 
 */
@Entity
@Table(name="Sprints")
@NamedQuery(name="Sprint.findAll", query="SELECT s FROM Sprint s")
public class Sprint implements Serializable {
	private static final long serialVersionUID = 1L;
	private int idSprints;
	private Date creationDate;
	private int duration;
	private Date endDate;
	private String name;
	private Date startDate;
	private Date updatedDate;
	private Project project;
	private User userCreatedBy;
	private User userUpdatedBy;
	private List<Task> tasks;

	public Sprint() {
	}


	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public int getIdSprints() {
		return this.idSprints;
	}

	public void setIdSprints(int idSprints) {
		this.idSprints = idSprints;
	}


	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreationDate() {
		return this.creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}


	public int getDuration() {
		return this.duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}


	@Temporal(TemporalType.TIMESTAMP)
	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}


	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}


	@Temporal(TemporalType.TIMESTAMP)
	public Date getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}


	@Temporal(TemporalType.TIMESTAMP)
	public Date getUpdatedDate() {
		return this.updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}


	//bi-directional many-to-one association to Project
	@ManyToOne
	@JoinColumn(name="idProject")
	public Project getProject() {
		return this.project;
	}

	public void setProject(Project project) {
		this.project = project;
	}


	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="CreatedBy")
	public User getUserCreatedBy() {
		return this.userCreatedBy;
	}

	public void setUserCreatedBy(User userCreatedBy) {
		this.userCreatedBy = userCreatedBy;
	}


	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="UpdatedBy")
	public User getUserUpdatedBy() {
		return this.userUpdatedBy;
	}

	public void setUserUpdatedBy(User userUpdatedBy) {
		this.userUpdatedBy = userUpdatedBy;
	}


	//bi-directional many-to-one association to Task
	@OneToMany(mappedBy="sprintBean")
	public List<Task> getTasks() {
		return this.tasks;
	}

	public void setTasks(List<Task> tasks) {
		this.tasks = tasks;
	}

	public Task addTask(Task task) {
		getTasks().add(task);
		task.setSprintBean(this);

		return task;
	}

	public Task removeTask(Task task) {
		getTasks().remove(task);
		task.setSprintBean(null);

		return task;
	}

}